import 'package:ad_plugin/ad_error.dart';
import 'package:ad_plugin/ad_listener.dart';
import 'package:ad_plugin/splash_ad.dart';
import 'package:flutter/material.dart';

/// FileName splash_ad
/// @Author zhuqingfang
/// @Date 2022/10/9 10:29 上午
/// @Description splash ad test
final splashAdTest = SplashAdTest();

class SplashAdTest {
  SplashAdTest._internal();

  static final SplashAdTest _instance = SplashAdTest._internal();

  factory SplashAdTest() => _instance;
  SplashAd? _splashAd;
  void load() {
    SplashAd.load(
        placementId: 'ca-app-pub-3940256099942544/3419835294',
        adLoadCallback: AdLoadCallback(
            onAdLoaded: (SplashAd splashAd) {
              _splashAd = splashAd;
              debugPrint('splash ad load');
            },
            onAdFailLoad: (SplashAd splashAd,LoadAdError adError) {
              debugPrint('splash ad load error $adError');
            }));
  }

  void show(){
    _splashAd?.contentCallback = ContentCallback(
        onAdShow: (SplashAd splashAd) {
          debugPrint('splashAd ad onShow');
        },
        onAdDismiss: (SplashAd splashAd) {
          debugPrint('splashAd ad onDismiss');
        },
        onAdClick: (SplashAd splashAd) {
          debugPrint('splashAd ad onClick');
        });
    _splashAd?.show();
  }

}
